package com.wxxymaker.utils;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Author: Soft
 * @Date: 2018-04-14 2:09
 * @Desc: 简单的缓存
 */
public class SimpleCache {
    private static final Map<String, Object> cache = new ConcurrentHashMap<>();

    public static void set(String key, Object val) {
        if (cache.containsKey(key)) {
            cache.remove(key);
        }
        cache.put(key, val);
    }

    public static Object get(String key) {
        if (cache.containsKey(key)) {
            return cache.get(key);
        }
        return null;
    }

    public static void remove(String key) {
        if (cache.containsKey(key)) {
            cache.remove(key);
        }
    }
}
